<!--
 @description 订单详情-产品信息
 @fileName ProductList.vue
 @author zengqiongying
 @created 2021/07/10 13:36:28
-->
<template>
  <div>
    <table-box
      ref="refTable"
      table-size="mini"
      :data="tableData"
      :table-config="tableConfig"
      :other-filters="otherFilters"
      :table-max-height="600"
      :show-custom-combine="false"
      :show-custom-setting="true"
      :table-sortable="true"
      show-index
    />
  </div>
</template>

<script>
import tabMixin from './mixin'
import { parseTime } from '@/utils'
export default {
  name: 'OrderDetailProduct',
  mixins: [tabMixin],
  data() {
    return {
      tableData: [],
      otherFilters: [], // 表格额外查询条件
      otherRaws: {},
      tableConfig: {
        // interfacePath: `${process.env.VUE_APP_BASE_API}/api/v1/orderProduct/page`,
        interfacePath: ``,
        // hideSearchBar: true,
        hideFuncBar: true,
        tabIndex: 22,
        buttonGroupCode: 'detail_product',
        pageSize: 50,
        // sort: 'soTime', // 开单时间
        // order: 'desc',
        setting: [
          {
            prop: 'skuCode',
            label: '商品编码',
            minWidth: 200
          },
          {
            prop: 'productCode',
            label: '产品编码',
            minWidth: 150
          },
          {
            prop: 'productName',
            label: '产品名称',
            minWidth: 150
          },
          {
            prop: 'buyQuantity',
            label: '购买数量',
            minWidth: 100,
            align: 'center'
          },
          {
            prop: 'closeQuantity',
            label: '售中关闭量',
            minWidth: 100,
            align: 'center'
          },
          {
            prop: 'returnQuantity',
            label: '售后关闭量',
            minWidth: 100,
            align: 'center'
          },
          {
            prop: 'takeupQuantity',
            label: '渠道库存占用量', // 渠道库存占用量= 渠道库存预占数量
            minWidth: 130,
            align: 'center'
          },
          {
            prop: 'purQuantity',
            label: '采购量',
            minWidth: 100,
            align: 'center'
          },
          {
            prop: 'soQuantity',
            label: '开单量',
            minWidth: 100,
            align: 'center'
          },
          {
            prop: 'soAuditQuantity',
            label: '销售审核量',
            minWidth: 100,
            align: 'center'
          },
          {
            prop: 'soDistQuantity',
            label: '配车量',
            minWidth: 100,
            align: 'center'
          },
          {
            prop: 'soSendQuantity',
            label: '启运量', // 启运量 = 发货量
            minWidth: 100,
            align: 'center'
          },
          {
            prop: 'soSignQuantity',
            label: '签收量',
            minWidth: 100,
            align: 'center'
          },
          {
            prop: 'storePlanQuantity',
            label: '排工量',
            minWidth: 100,
            align: 'center'
          },
          {
            prop: 'storeSendQuantity',
            label: '出库量',
            minWidth: 100,
            align: 'center'
          },
          {
            prop: 'storeFinishQuantity',
            label: '完工量',
            minWidth: 100,
            align: 'center'
          },
          {
            prop: 'storeComfirmQuantity',
            label: '确认量',
            minWidth: 100,
            align: 'center'
          },
          {
            prop: 'purOrderCode',
            label: '采购订单号1',
            minWidth: 150
          },
          {
            prop: 'purOrderCode2',
            label: '采购订单号2',
            minWidth: 150
          },
          {
            prop: 'saleOrderCode',
            label: '销售订单号',
            minWidth: 150
          },
          {
            prop: 'channelStockCodes',
            label: '渠道库存号',
            minWidth: 200
          },
          {
            prop: 'sendState',
            label: '发货状态',
            minWidth: 120,
            type: 'select',
            propEnum: {
              domainCode: 'marketing',
              appCode: 'eco',
              dictTypeCode: 'SEND_STATUS'
            }
          },
          {
            prop: 'returnState',
            label: '关闭状态',
            minWidth: 120,
            type: 'select',
            propEnum: {
              domainCode: 'marketing',
              appCode: 'eco',
              dictTypeCode: 'RETURN_STATUS'
            }
          },
          {
            prop: 'purTime',
            label: '采购时间',
            minWidth: 150,
            formatData: ({ purTime }) => {
              return parseTime(purTime)
            }
          },
          {
            prop: 'soTime',
            label: '开单时间',
            minWidth: 150,
            formatData: ({ soTime }) => {
              return parseTime(soTime)
            }
          },
          {
            prop: 'soAuditTime',
            label: '销售审核时间',
            minWidth: 150,
            formatData: ({ soAuditTime }) => {
              return parseTime(soAuditTime)
            }
          },
          {
            prop: 'withcarTime', // soDistTime
            label: '配车时间',
            minWidth: 150,
            formatData: ({ withcarTime }) => {
              return parseTime(withcarTime)
            }
          },
          {
            prop: 'transportTime',
            label: '发货时间', // 发货时间 = 启运时间
            minWidth: 150,
            formatData: ({ transportTime }) => {
              return parseTime(transportTime)
            }
          },
          {
            prop: 'signTime',
            label: '签收时间',
            minWidth: 150,
            formatData: ({ signTime }) => {
              return parseTime(signTime)
            }
          },
          {
            prop: 'storePlanTime',
            label: '排工时间',
            minWidth: 150,
            formatData: ({ storePlanTime }) => {
              return parseTime(storePlanTime)
            }
          },
          {
            prop: 'storeSendTime',
            label: '出库时间',
            minWidth: 150,
            formatData: ({ storeSendTime }) => {
              return parseTime(storeSendTime)
            }
          },
          {
            prop: 'completionTime',
            label: '完工时间',
            minWidth: 150,
            formatData: ({ completionTime }) => {
              return parseTime(completionTime)
            }
          },
          {
            prop: 'storeComfirmTime',
            label: '确认时间',
            minWidth: 150,
            formatData: ({ storeComfirmTime }) => {
              return parseTime(storeComfirmTime)
            }
          }
        ],
        btnList: []
      }
    }
  },
  computed: {

  },
  created() {
    /* this.otherFilters = [
      { id: 'orderId', property: 'orderId', operator: '=', value: this.orderId }
    ] */
  },
  methods: {
    initData() {
      const productList = (this.orderData && this.orderData.productList) || []
      const skuList = (this.orderData && this.orderData.skuList) || []
      this.tableData = this.sortGroup(skuList, productList)

      /* this.otherFilters = [
        { id: 'orderId', property: 'orderId', operator: '=', value: this.orderId }
      ]
      this.$nextTick(() => {
        this.$refs.refTable.initTableData()
      }) */
    },
    sortGroup(skuList, productList) {
      let resList = []
      skuList.forEach(sku => {
        const tmp = productList.filter(v => v.ecSkuId === sku.id)
        resList = [...resList, ...tmp]
      })
      return resList
    },
    settingTable() {
      this.$refs.refTable.getMore('setting')
    }
  }
}

</script>
<style lang='scss' scoped>
</style>
